import { useNavigate } from 'react-router-dom'
/* -------------------------------------------------------- Sync Function -- */
import Logout from '@com/login/logout'
import ClearCache from '@com/login/clearCache'
/**
 * 用户操作控制组件
 * @return {Component} 
 */
const Index = ({ api='user/logout' }) => {
	const navigate = useNavigate( )
	
	const onLogout = ()=> Logout({ api, navigate })
	
	const onClear = () => ClearCache()
	
	const user = window.$fn.getUser()
	
	return (
		<div className='ex pr20 f12 fxmr'>
			{
				user?.name && <div>欢迎 <span className='c0'>{user?.name}</span></div>
			}
			<span className='cp g6 hover tap db plr10' onClick={onLogout}>退出登录</span>
			<span className='cp g6 hover tap db plr10' onClick={onClear}>刷新缓存</span>
		</div>
	)
}
export default Index